package com.teamfractal.fracdustry.common.container.init;

import com.teamfractal.fracdustry.common.container.Generators.FDKineticGeneratorContainer;
import com.teamfractal.fracdustry.common.container.Generators.FDMicrowaveGeneratorContainer;
import com.teamfractal.fracdustry.common.container.Generators.FDSolarGeneratorContainer;
import com.teamfractal.fracdustry.common.container.Generators.FDThermalGeneratorContainer;
import com.teamfractal.fracdustry.common.container.Machines.FDElectricFurnaceContainer;
import com.teamfractal.fracdustry.common.container.Machines.FDOreProcessorContainer;
import com.teamfractal.fracdustry.common.container.datasync.SimpleArray;
import com.teamfractal.fracdustry.common.util.FDRegistryHandler;
import net.minecraft.core.BlockPos;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.extensions.IForgeContainerType;
import net.minecraftforge.fmllegacy.RegistryObject;

public class FDContainers {
    public static RegistryObject<MenuType<FDKineticGeneratorContainer>> containerKineticGenerator;
    public static RegistryObject<MenuType<FDThermalGeneratorContainer>> containerThermalGenerator;
    public static RegistryObject<MenuType<FDMicrowaveGeneratorContainer>> containerMicrowaveGenerator;
    public static RegistryObject<MenuType<FDSolarGeneratorContainer>> containerSolarGenerator;

    public static RegistryObject<MenuType<FDOreProcessorContainer>> containerOreProcessor;
    public static RegistryObject<MenuType<FDElectricFurnaceContainer>> containerElectricFurnace;

    public static void register(){
        containerKineticGenerator = FDRegistryHandler.Containers.register("kinetic_generator", () -> IForgeContainerType.create((windowId, inv, data) -> {
            BlockPos pos = data.readBlockPos();
            Level world = inv.player.getCommandSenderWorld();
            SimpleArray currentEnergy = new SimpleArray();
            SimpleArray maxEnergy = new SimpleArray();
            return new FDKineticGeneratorContainer(windowId, world, pos, inv, inv.player, currentEnergy, maxEnergy);
        }));

        containerThermalGenerator = FDRegistryHandler.Containers.register("thermal_generator", () -> IForgeContainerType.create((windowId, inv, data) -> {
            BlockPos pos = data.readBlockPos();
            Level world = inv.player.getCommandSenderWorld();
            SimpleArray fuel = new SimpleArray();
            SimpleArray currentEnergy = new SimpleArray();
            SimpleArray maxEnergy = new SimpleArray();
            return new FDThermalGeneratorContainer(windowId, world, pos, inv, inv.player, fuel, currentEnergy, maxEnergy);
        }));

        containerMicrowaveGenerator = FDRegistryHandler.Containers.register("microwave_generator", () -> IForgeContainerType.create((windowId, inv, data) -> {
            BlockPos pos = data.readBlockPos();
            Level world = inv.player.getCommandSenderWorld();
            SimpleArray currentEnergy = new SimpleArray();
            SimpleArray maxEnergy = new SimpleArray();
            return new FDMicrowaveGeneratorContainer(windowId, world, pos, inv, inv.player, currentEnergy, maxEnergy);
        }));

        containerSolarGenerator = FDRegistryHandler.Containers.register("solar_generator", () -> IForgeContainerType.create((windowId, inv, data) -> {
            BlockPos pos = data.readBlockPos();
            Level world = inv.player.getCommandSenderWorld();
            SimpleArray currentEnergy = new SimpleArray();
            SimpleArray maxEnergy = new SimpleArray();
            return new FDSolarGeneratorContainer(windowId, world, pos, inv, inv.player, currentEnergy, maxEnergy);
        }));


        containerOreProcessor = FDRegistryHandler.Containers.register("ore_processor", () -> IForgeContainerType.create((windowId, inv, data) -> {
            BlockPos pos = data.readBlockPos();
            Level world = inv.player.getCommandSenderWorld();
            SimpleArray processNow = new SimpleArray();
            SimpleArray processTotal = new SimpleArray();
            SimpleArray currentEnergy = new SimpleArray();
            SimpleArray maxEnergy = new SimpleArray();
            return new FDOreProcessorContainer(windowId, world, pos, inv, inv.player, processNow, processTotal, currentEnergy, maxEnergy);
        }));
        containerElectricFurnace = FDRegistryHandler.Containers.register("electric_furnace", () -> IForgeContainerType.create((windowId, inv, data) -> {
            BlockPos pos = data.readBlockPos();
            Level world = inv.player.getCommandSenderWorld();
            SimpleArray processNow = new SimpleArray();
            SimpleArray processTotal = new SimpleArray();
            SimpleArray currentEnergy = new SimpleArray();
            SimpleArray maxEnergy = new SimpleArray();
            return new FDElectricFurnaceContainer(windowId, world, pos, inv, inv.player, processNow, processTotal, currentEnergy, maxEnergy);
        }));
    }

}
